package com.gooagoo.supercrm.app;

import android.content.Context;
import android.os.Environment;
import android.os.Handler;
import android.support.multidex.MultiDexApplication;

import com.gooagoo.supercrm.net.ApiService;
import com.gooagoo.supercrm.net.RetrofitManager;

import java.util.HashMap;

/**
 * Created by admin on 2016/8/9.
 */

public class CustomApplication extends MultiDexApplication {
    public static String BITMAP_CACHE_DIR = Environment.getExternalStorageDirectory().toString() + "/BAL/bitmap_cache/";
    public static HashMap<String, String> tasks = new HashMap<>();
    public static String chatId;
    public static Context context;
    private static int mainThreadId;
    private static Handler handler;
    private static ApiService service;


    // 网络请求
//    public static ApiService service = null;



    @Override
    public void onCreate() {
        super.onCreate();
        context = getApplicationContext();
        ActivityStackManager.getInstance().register(this);
        mainThreadId = android.os.Process.myTid();// 获取当前主线程id
        handler = new Handler();
        initErrorHandler();
        ConfigureLog4J log4j = new ConfigureLog4J();
        setService();
    }

    public static void setService() {
        try {
            service = RetrofitManager.getInstance().getService();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    private void initErrorHandler()
    {
        CrashHandler handler = CrashHandler.getInstance();
        handler.init(getApplicationContext());
    }
    public static int getMainThreadId() {
        return mainThreadId;
    }



    public static Handler getHandler() {
        return handler;
    }

}


